// src/services/category.ts

import { useMemberStore } from "@/stores";
import { BaseURL } from "@/stores/modules/base";
import type { CategoryTopItem } from "@/types/category";
import type { PageResult } from "@/types/mycontribute";
import type { PageQuery } from "@/types/mycontribute";
import { http, httpR2 } from "@/utils/http";

/**
 * 分类列表-小程序
 */
export const getCategoryTopAPI = () => {
  return http<CategoryTopItem[]>({
    method: "GET",
    url: "/category/top",
  });
};

export const getContributeResult = (query: PageQuery) => {
  return httpR2<PageResult>({
    method: "POST",
    url: BaseURL + "/user/contribute/page",
    header: {
      authorization: useMemberStore().profile.authorization,
    },
    data: {
      ...query,
    },
  });
};
